package Demo;

import static java.lang.Thread.sleep;

class MyThread extends Thread{
    public void run(){
        // run方法是线程的入口方法
        while(true) {
            System.out.println("hello Thread");
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
               e.printStackTrace();
            }
        }
    }
}
public class test {
    public static void main(String[] args) throws InterruptedException {
        MyThread myThread = new MyThread();
        // run和start都是Thread的成员,start调用创建线程，线程再调用run方法
         myThread.start();
        // myThread.run();
        // 这句就是主动调用run,先执行完run的代码才会向下继续执行,就是单线程的执行流了
        while(true){
            System.out.println("hello main");
            Thread.sleep(1000);
        }
        // 两者交替执行,并发执行
    }
}



/*
class Solution {
    public boolean hasPathSum(TreeNode root, int targetSum) {
       if(root == null){
        return false;
       }

       targetSum -= root.val;
       if(root.left == null && root.right == null){
        return targetSum == 0;
       }

       return hasPathSum(root.left,targetSum) || hasPathSum(root.right,targetSum);
    }
}
*/